using System.Threading.Tasks;
using Xunit;
using YouTrackSharp.Tests.Infrastructure;

// ReSharper disable once CheckNamespace
namespace YouTrackSharp.Tests.Integration.Issues
{
    public partial class IssuesServiceTests
    {
        public class AttachFileToIssue
        {
            [Fact]
            public async Task Valid_Connection_Attaches_Single_File_To_Issue()
            {
                // Arrange
                var connection = Connections.Demo1Token;
                using (var temporaryIssueContext = await TemporaryIssueContext.Create(connection, GetType()))
                {
                    var service = connection.CreateIssuesService();
                    
                    // Act & Assert
                    using (var attachmentStream = await TestUtilities.GenerateAttachmentStream("Generated by unit test."))
                    {
                        await service.AttachFileToIssue(temporaryIssueContext.Issue.Id, "singlefile.txt", attachmentStream, attachmentContentType: "text/plain");
                    }

                    await temporaryIssueContext.Destroy();
                }
            }
        }
    }
}